package headfirst.designpatterns.factory.c_pizzaaf_abstartfactory.b_pizza;

import headfirst.designpatterns.factory.c_pizzaaf_abstartfactory.a_ingredientFactory.PizzaIngredientFactory;
import headfirst.designpatterns.factory.c_pizzaaf_abstartfactory.ingredient.cheese.Cheese;

/**
 * 工厂方法子类
 */
public class CheesePizza extends Pizza {
	PizzaIngredientFactory ingredientFactory;
 
	public CheesePizza(PizzaIngredientFactory ingredientFactory) {
		this.ingredientFactory = ingredientFactory;
	}

	/**
	 * 工厂方法 实现抽象工厂中的产品族
	 */
	public void prepare() {
		System.out.println("Preparing " + name);
		dough = ingredientFactory.createDough();
		sauce = ingredientFactory.createSauce();
		cheese = ingredientFactory.createCheese();
	}
}
